package com.demo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.domain.vo.MyTeamView;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MyTeamViewDao extends BaseMapper<MyTeamView> {//    根据用户uid找到其参与的队伍、以及队伍的信息
    @Select("select tc.tc_uid,tc.tc_urealname,tc.tc_team_id,tc.tc_member_type,tp.* \n" +
            "from tb_team_profile as tp,tb_team_composition as tc\n" +
            "where tp.tp_alive=1 and tp.tp_id=tc.tc_team_id and tc.tc_uid=#{uid}")
    @Results({@Result(column = "tc_uid",property = "uid"),
            @Result(column = "tc_urealname",property = "urealname"),
            @Result(column = "tc_team_id",property = "teamId"),
            @Result(column = "tc_member_type",property = "memberType"),
            @Result(column = "tp_id",property = "team.tpId"),
            @Result(column = "tp_uid",property = "team.tpUid"),
            @Result(column = "tp_urealname",property = "team.tpUrealname"),
            @Result(column = "tp_team_name",property = "team.tpTeamName"),
            @Result(column = "tp_project_name",property = "team.tpProjectName"),
            @Result(column = "tp_member_number",property = "team.tpMemberNumber"),
            @Result(column = "tp_teacher_number",property = "team.tpTeacherNumber"),
            @Result(column = "tp_recruit_total_number",property = "team.tpNeedStudentNumber"),
            @Result(column = "tp_lack_student_number",property = "team.tpDifference"),
            @Result(column = "tp_registration_deadline",property = "team.tpRegistrationDeadline"),
            @Result(column = "tp_contact",property = "team.tpContact"),
            @Result(column = "tp_teacher_name",property = "team.tpTeacherName"),
            @Result(column = "tp_team_intro",property = "team.tpTeamIntro"),
            @Result(column = "tp_ability_need",property = "team.tpAbilityNeed"),
    })
    List<MyTeamView> selectMyTeamByUid(Long uid);

}
